import {getToken} from "../utils/auth";

const routeTable = [
    {
        path: '/login',
        view: () => import('../views/Login')
    },
    {
        path: '/',
        view: () => import('../layout'),
        children: [
            {
                path: '/netdisk',
                view: () => import('../views/Netdisk'),
                children: [
                    {
                        path: '/netdisk/space',
                        view: () => import('../views/Netdisk/Space')
                    },
                    {
                        path: '/',
                        redirect: '/netdisk/space'
                    }
                ]
            },
            {
                path: '/spider',
                view: () => import('../views/Spider')
            },
            {
                path: '/',
                redirect: '/netdisk/space'
            }
        ]
    }
]

 function beforeEach(route) {
    if (getToken()) return route.path
     else return '/login'
 }

 export { beforeEach }

 export default routeTable